import 'package:flutter/material.dart';

class G {
  /// money
  static Widget toMoney(BuildContext context, double price) {
    return Expanded(
      child: Row(
        children: [
          Text(
            "￥",
            style: Theme.of(context)
                .textTheme
                .bodyText2
                ?.merge(const TextStyle(color: Colors.red)),
          ),
          Text(
            "$price",
            style: Theme.of(context)
                .textTheme
                .bodyText1
                ?.merge(const TextStyle(color: Colors.red)),
          ),
        ],
      ),
    );
  }

  /// appbar 顶部搜索
  static AppBar appbarSearch(
    BuildContext context,
    Widget right,
  ) {
    return AppBar(
      titleSpacing: 0,
      leadingWidth: 20,
      title: Row(
        children: [
          Expanded(
            child: Container(
              padding: const EdgeInsets.only(left: 20),
              height: 28,
              child: TextField(
                onEditingComplete: () {
                  Navigator.pushNamed(context, '/search');
                },
                textAlignVertical: TextAlignVertical.center,
                decoration: const InputDecoration(
                  hintText: "搜索你想要的商品",
                  filled: true,
                  fillColor: Colors.white,
                  prefixIcon: Icon(Icons.search, size: 18),
                  isCollapsed: true,
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.all(Radius.circular(50)),
                  ),
                ),
              ),
            ),
          ),
          right
        ],
      ),
    );
  }
}
